package com.yh.service.impl;

import com.yh.entity.SysUserRole;
import com.yh.mapper.SysUserRoleMapper;
import com.yh.service.ISysUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户和角色关联表 服务实现类
 * </p>
 *
 * @author yh
 * @since 2021-05-10
 */
@Service
@AllArgsConstructor
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {
    private SysUserRoleMapper sysUserRoleMapper;

    @Override
    public Page<SysUserRole> getPageSysUserRole(Integer pageNum, Integer pageSize){
        Page<SysUserRole>userPage = sysUserRoleMapper.selectPage(new Page<>(pageNum,pageSize),new LambdaQueryWrapper<>());
        return userPage;
    }

    @Override
    public SysUserRole saveSysUserRole (SysUserRole sysUserRole) {
        sysUserRoleMapper.insert(sysUserRole);
        return sysUserRole;
    }

    @Override
    public SysUserRole updateSysUserRole(SysUserRole sysUserRole) {
        sysUserRoleMapper.updateById(sysUserRole);
        return sysUserRole;
    }

    @Override
    public SysUserRole getInfo(String id) {
        return sysUserRoleMapper.selectById(id);
    }
}
